<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8" />
	<title>个人信息</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-touch-fullscreen" content="yes">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<link rel="stylesheet" href="/qstatic/css/reset.css" />
	<link rel="stylesheet" href="/qstatic/css/animate.css" />
	<link rel="stylesheet" href="/qstatic/css/swiper-3.4.1.min.css" />
	<link rel="stylesheet" href="/qstatic/css/layout.css" />
	
	<script src="/qstatic/js/jquery-1.9.1.min.js"></script>
	<script src="/qstatic/js/zepto.min.js"></script>
	<script src="/qstatic/js/fontSize.js"></script>
	<script src="/qstatic/js/swiper-3.4.1.min.js"></script>
	<script src="/qstatic/js/wcPop/wcPop.js"></script>
	
		<script src="/qstatic/js/layui.js"></script>
	<link rel="stylesheet" href="/qstatic/js/css/layui.css" />
</head>
<body>
	
	<!-- <>微聊主容器 -->
	<div class="wechat__panel clearfix">
		<div class="wc__home-wrapper flexbox flex__direction-column">
			<!-- //顶部 -->
			<div class="wc__headerBar fixed">
				<div class="inner flexbox">
					<a class="back" href="javascript:;" onclick="history.back(-1);"></a>
					<h2 class="barTit flex1">个人信息</h2>
					<!--<a class="batBtn" href="javascript:;">保存</a>-->
				</div>
			</div>

			<!-- //个人信息页 -->
			<div class="wc__ucinfoPanel">
				<div class="wc__ucinfo-personal">
					<ul class="clearfix">
						<li>
							<div class="item flexbox flex-alignc wc__material-cell">
								<label class="lbl flex1">头像</label>
								<div id="shopimgdata">
								<img class="uimg"  src="{:tx(session('uid'))}" />
								     </div>
									 <!--id="uptpzt"<input type="file" accept="image/*" id="idzfilezt" style="display: none;">-->
								<input class="chooseImg" type="file" id="idzfilezt" accept="image/*" />
							</div>
							<div class="item flexbox flex-alignc wc__material-cell">
								<label class="lbl flex1">昵称</label>
								<a onclick="inputname()"><input class="val" type="text" value="{:username(session('uid'))}" readonly="readonly"/></a>
							</div>
							<div class="item flexbox flex-alignc wc__material-cell">
								<label class="lbl flex1">微聊号</label>
								<input class="val" type="text" value="{:session('name')}" readonly="readonly"/>
							</div>
							<!--<div class="item flexbox flex-alignc wc__material-cell">-->
							<!--	<textarea class="area flex1" placeholder="请输入个性签名"></textarea>-->
							<!--</div>-->
						</li>
					</ul>
				</div>
			</div>

		</div>
	</div>


	<script type="text/javascript">
	
	
	function inputname(){
        layer.prompt({title: '请输入新的昵称'}, function(value, index, elem){
        if(value === '') return elem.focus();
        var regex = /^[^\s`~!@#$%^&*()\-+={}\[\]:;"'<>,.?\\/]+$/;
        if(!regex.test(value)) {
            layer.msg('输入内容包含特殊字符，请重新输入！');
            return false; // 阻止 prompt 关闭
        }
    
        $.post("/chat/updatename", {name: value}, function(data, status) {
            // 成功回调函数
            console.log("Data: " + data);
            
            if(data.code == "1"){
                layer.msg(data.msg)
                setTimeout(function() {
                    location.reload();
                }, 2000);
            }else{
                layer.msg(data.msg)
            }
        })
    
    
        
        layer.close(index);
        });
    }
	
		/** __公共函数 */
		$(function(){
			// ...
		});
		
		/** __自定函数 */
		$(function(){
		$("#uptpzt").click(function(){
        $("#idzfilezt").click();
});
$("#uptpztzt").click(function(){
        $("#idzfilezt").click();
});
			// ...
		});

		//头像上传
		function uploadPictx(formData) {
            var oReq = new XMLHttpRequest();
            oReq.open("POST", "/chat/mytx?name=74&kf=14&zt=0", true);
            oReq.onload = function (oEvent) {
                if (oReq.status == 200) {
					//msgWrapper.innerHTML += oReq.response;
					//$('#msgWrapper').scrollTop( $('#msgWrapper')[0].scrollHeight );//滚动条至底部
					html=oReq.response;
					$('#shopimgdata').html(html);

					// $('#uptpzt').html(html);

                } else {
					//msgWrapper.innerHTML += '';
					//document.getElementById("msgWrapper").innerHTML=oReq.status;

                }
            };

            oReq.send(formData);
        }


//用户头像上传
	$("#idzfilezt").change(function(){
	//console.log('头像主图');
    lrz(this.files[0],{width:800})
    .then(function (rst) {
        // 处理成功会执行
		//$('#shopimgdata').html('<img src="/Public/images/dd.gif">');
		//Toast('图片已经提交请耐心等待',5500)
		//Tmsg('上传成功',2);
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile2';
		//console.log(img.src);
		uploadPictx(img.src);
       // up_ajax(rst.base64,type);

    });
});

	$("#photoFile").change(function(){
	//console.log('主图');
    lrz(this.files[0],{width:800})
    .then(function (rst) {
        // 处理成功会执行
		Toast('图片已经提交请耐心等待',5500)
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile2';
		//console.log(img.src);
		uploadPic(img.src);
       // up_ajax(rst.base64,type);

    });
});

function Tmsg(msg,time){
	 wcPop({
      anim: 'fadeIn',
      content: msg,
      shade: true,
      shadeClose: false,
      time: time
    });
	/**
				var aboutChat = wcPop({
					skin: 'ios',
					content: '<div>'+msg+'</div>',
					//style: 'max-width: 750px',

					shadeClose:true,

					btns: [
						{
							text: '知道了',
							style: 'color:#5c93fd;',
							onTap() {
								wcPop.close(aboutChat);
							}
						}
					]
				});
				**/
		
}

function Toast(msg,duration){  
    duration=isNaN(duration)?3000:duration;  
    var m = document.createElement('div');  
    m.innerHTML = msg;  
    m.style.cssText="width: 60%;min-width: 150px;opacity: 0.7;height: 30px;color: rgb(255, 255, 255);line-height: 30px;text-align: center;border-radius: 5px;position: fixed;top: 40%;left: 20%;z-index: 999999;background: rgb(0, 0, 0);font-size: 12px;";  
    document.body.appendChild(m);  
    setTimeout(function() {  
        var d = 0.5;  
        m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';  
        m.style.opacity = '0';  
        setTimeout(function() { document.body.removeChild(m) }, d * 1000);  
    }, duration);  
}  

	</script>
	<script src="/qstatic/js/lrz/lrz.all.bundle.js" type="text/javascript"></script>
</body>

</html>
